@extends("admin_system/public/layout")

@section('content')
    <div class="col-xs-12 top-nav nav">
        <p class="float-left nav-path"><strong>当前位置：</strong>企业管理>>企业列表</p>

        {{--返回按钮--}}
        <button type="button" class="btn btn-default float-right back" aria-label="Left Align">
            <span class="glyphicon glyphicon-arrow-left back" aria-hidden="true"></span>
            <span>返回</span>
        </button>
    </div>





    <div class="content-box col-xs-12 mt20 pb20 pt20">

        <form class="form-inline nav mb10" method="get" action="{{asset('admin_system/company/company_list')}}">
            <div class="form-group">
                <div class="input-group">
                    <div class="input-group-addon">查询</div>
                    <input name="keywords" class="form-control"  placeholder="按公司名称查询" value="{{$keywords}}">
                    {{csrf_field()}}
                </div>
            </div>
            <button type="submit" class="btn btn-primary">搜索</button>
        </form>


        <table class="table table-hover table-bordered">
            <tr>
                <th>编号</th>
                <th>企业名称</th>
                <td>管理员</td>
                <td>联系电话</td>
                <th>端口总数</th>
                <th>员工数</th>
                <th>会员有效期</th>
                <th>公司读书会</th>
                <th>公司编号</th>
                <th>操作</th>
            </tr>


            @foreach($companys as $com)
                <tr id="company-{{$com->company_id}}" data-name="{{$com->company_name}}">
                    <td>{{$com->company_id}}</td>
                    <td>{{$com->company_name}}</td>
                    <td>{{$com->manager}}</td>
                    <td>{{$com->mobile}}</td>
                    <td>{{$com->vip_port}}</td>
                    {{--<td>{{$com->surplus_port}}</td>--}}
                    <td><a href="{{asset('admin_system/company/members?companyId='.$com->company_id)}}">{{$com->countEmployee}}</a></td>
                    <td>始:{{$com->vip_begin_date}}<br/>止:{{$com->vip_end_date}}</td>
                    <td>
                        @foreach($com->readPartys as $read)
                            <p>
                                <a href="{{asset('admin_system/readingparty/members?readId='.$read->ReaParID)}}" class="btn btn-default" aria-label="Left Align">
                                    {{$read->ReaParName}}
                                    <span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span>
                                </a>
                            </p>
                        @endforeach
                        <p>
                            <a href="{{asset('admin_system/readingparty/index/0/edit?companyId='.$com->company_id)}}" class="btn btn-ms btn-primary" aria-label="Left Align">创建读书会
                                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                            </a>
                        </p>
                    </td>
                    <td>{{$com->company_sn}}</td>
                    <td>
                        <a href="{{asset('admin_system/company/company_detail?companyId='.$com->company_id)}}" class="btn btn-xs btn-info">编辑</a>
                        <a href="{{asset('admin_system/company/delete?companyId='.$com->company_id)}}" class="btn btn-xs btn-danger" onclick="return confirm('确定彻底删除？')">删除</a>
                        {{--<p class="btn btn-xs btn-danger" onclick="show_add_department_model({{$com->company_id}})">添加部门</p>--}}
                    </td>
                </tr>
            @endforeach
        </table>


        {!! $companys->appends(['keywords'=>$keywords])->links() !!}

    </div>




    {{--添加部门--}}
    <div class="modal fade" id="add-department-model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">添加给【<span id="company-name"></span>】添加部门</h4>
                </div>

                <div class="modal-body">
                    <form method="post" action="{{asset('/admin_system/company/department_update')}}">
                        <div class="form-group">
                            {{csrf_field()}}
                            <label for="recipient-name" class="control-label">部门名称:</label>
                            <input type="text" class="form-control" name="department_name" required>
                            <input type="hidden" name="company_id" id="dep-com-id" required>
                        </div>


                        <div class="modal-footer">
                            <button class="btn btn-danger">提交</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>




@endsection